package com.trainoo.payment.mock.util;

import com.trainoo.payment.mock.cache.PayerIdCache;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;

import java.util.Date;

/**
 * @author yongzou
 * @description
 * @date 2023/9/4 5:58 PM
 **/
public class PayerGenUtil {

    public static PayerIdCache genPayerIdAndFourthTransNo() {
        String fourthTransNo;
        String payerId;
        // 0 - 9的数
        int i = RandomUtils.nextInt(0, 10);
        //模拟微信支付的多
        if (i < 7) {
            fourthTransNo = "420000" + "1916" + DateUtil.getDateFormat(new Date(), DateUtil.yyyyMMdd) + RandomStringUtils.randomNumeric(10);
            payerId = "o-Rj7w" + RandomStringUtils.randomAlphanumeric(10) + "-" + RandomStringUtils.randomAlphanumeric(11);

        } else if (i < 9) {
            //支付宝
            fourthTransNo = DateUtil.getDateFormat(new Date(), DateUtil.YMDSTRING_DATA) + RandomStringUtils.randomNumeric(14);
            payerId = "2088" + RandomStringUtils.randomNumeric(12);

        } else {
            //其它
            fourthTransNo = "100000" + RandomStringUtils.randomNumeric(12);
            payerId = "other" + RandomStringUtils.randomAlphanumeric(11);

        }
        PayerIdCache payerIdCache = new PayerIdCache();
        payerIdCache.setPayerId(payerId);
        payerIdCache.setFourthTransNo(fourthTransNo);
        return payerIdCache;
    }
}
